#include <iostream>
#include <boost/python.hpp>
#include "dummy.h"

static int _argc;

namespace bp = boost::python;

class DummyWrapper : public Dummy, public bp::wrapper<Dummy>
{
public:
    DummyWrapper(const bp::list &args)
        : Dummy(_argc, DummyWrapper::make_argv(args))
    {
    }

    static char **make_argv(const bp::list &args)
    {
        _argc = bp::len(args);
        char **argv = new char*[_argc];

        for (int i = 0; i < _argc; ++i) {
            argv[i] = bp::extract<char *>(args[i]);
            fprintf(stderr, "[%s] argv[%d]: %s\n", __FUNCTION__,
                                                   i, argv[i]);
        }

        return argv;
    }
};

BOOST_PYTHON_MODULE(dummy)
{
    bp::class_<DummyWrapper, boost::noncopyable> ("Dummy", bp::init<bp::list> ())
        .add_property("argNum", &Dummy::argNum)
    ;
}

